package net.citrite.android;

import com.android.SdkConstants;

/**
 * Return true if the given style re
 */
public class ResourceHelper {

    public static boolean isProjectStyle(String style) {
        return style.startsWith(SdkConstants.STYLE_RESOURCE_PREFIX);
    }

    public static String styleToTheme(String style) {
        if (style.startsWith(SdkConstants.STYLE_RESOURCE_PREFIX)) {
            style = style.substring(SdkConstants.STYLE_RESOURCE_PREFIX.length());
        } else if (style.startsWith(SdkConstants.ANDROID_STYLE_RESOURCE_PREFIX)) {
            style = style.substring(SdkConstants.ANDROID_STYLE_RESOURCE_PREFIX.length());
        } else if (style.startsWith(SdkConstants.PREFIX_RESOURCE_REF)) {
            // @package:style/foo
            int index = style.indexOf('/');
            if (index != -1) {
                style = style.substring(index + 1);
            }
        }
        return style;
    }
}
